package com.vrsys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vrsys.domain.Product;
import com.vrsys.persistence.ProductMapper;
import com.vrsys.view.PageQuery;

@Service
public class ProductService extends BaseService {
    @Autowired
    private ProductMapper productMapper;

    public PageQuery<Product> pagingProducts(PageQuery<Product> pageQuery) throws Exception{
       List<Product> products = productMapper.getProducts(pageQuery.getLanguage(),pageQuery.getFromIndex(),pageQuery.getElementNumber());

       pageQuery.setData(products);
//       if(0 < pageQuery.getData().size())
//           pageQuery.setFromIndex(pageQuery.getFromIndex() + pageQuery.getElementNumber());
    return pageQuery;
    }

    public Product queryDetailsBytId(int pid) {
        return productMapper.queryDetailsBytId(pid);
    }
}
